//
//  BHCompetitionDetailNavBar.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/6/15.
//

import UIKit
@objc protocol BHCompetitionDetailNavBarDelegate: NSObjectProtocol {
    func navigationBarDidBackAction()
    func navigationBarDidShareOrCollectAction(type: Int, collectOrNot: Bool)
}



class BHCompetitionDetailNavBar: UIView {

    @IBOutlet weak var title_label: UILabel!
    @IBOutlet weak var collectBtn: UIButton!
    @IBOutlet weak var shareBtn: UIButton!
    
    
    var delegate: BHCompetitionDetailNavBarDelegate?
    
    var collected: Bool = false {
        didSet {
            self.collectBtn.isSelected = collected
        }
    }
    
    
    static func loadFromXib() -> BHCompetitionDetailNavBar {
        let viewArray = Bundle.main.loadNibNamed("BHCompetitionDetailNavBar", owner: nil, options: nil)
        let view: BHCompetitionDetailNavBar = viewArray![0] as! BHCompetitionDetailNavBar
        return view
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        self.backgroundColor = UIColor.white.withAlphaComponent(0)
    }
    
    
    // 返回
    @IBAction func backDidAct(_ sender: UIButton) {
        self.delegate?.navigationBarDidBackAction()
    }
    
    @IBAction func collectDidAct(_ sender: UIButton) {
        self.delegate?.navigationBarDidShareOrCollectAction(type: 1, collectOrNot: true)
    }
    
    @IBAction func shareDidAct(_ sender: UIButton) {
        self.delegate?.navigationBarDidShareOrCollectAction(type: 0, collectOrNot: false)
    }
    
    
    static var bottomHeight: CGFloat {
        get {
            return UIScreen.begainY
        }
    }
    
}
